﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        var capturedValues = [];
        function getCapturedValue() {
            var obtainedValue;
            if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1)
                obtainedValue = window.frames["contenedor"].contentDocument.getElementById("tiempoJs").value;
            else
                obtainedValue = window.frames["contenedor"].document.getElementById("tiempoJs").value;
                
            capturedValues.push(obtainedValue);
            //alert("Valor capturado " + obtainedValue);
        }
        //Invocar al boton que ejecuta la medicion en la pagina original de carga
        function invokeInternalAction() {
            if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1)
                window.frames["contenedor"].contentDocument.getElementById("botonClick").click();
            else
                window.frames["contenedor"].document.getElementById("botonClick").click();
                

        }

        function repeatableInvoker() {
            for (var i = 0; i < 385; i++) {
                window.frames["contenedor"].location = "http://localhost:2874/Class%20Attribute/AddClassPrototype.html";
                invokeInternalAction();
                getCapturedValue()
            }


            var sumatoria = 0;
            for (var i = 0; i < capturedValues.length; i++) {
                sumatoria += parseFloat(capturedValues[i]);
            }
            var promedio = sumatoria / capturedValues.length;
            alert("Promedio: " + promedio)
        }

    </script>
    <style type="text/css">
        #urlText {
            width: 941px;
        }
    </style>
</head>
<body>
    <p>Frame principal</p>
    <p>Url:
        <input id="urlText" type="text" /></p>
    <input type="button" name="captureMetric" value="Capture" onclick="getCapturedValue()" />
    <input type="button"  value="Invoke" onclick="invokeInternalAction()" />
    <input type="button" name="RepeteableInvoker" value="Repeteable Invoker" onclick="repeatableInvoker()" />
    <iframe id="contenedor" src="AddClassPrototype.html" width="100%" height="80%"></iframe>
</body>
</html>
